#pragma once

#include <iostream>
#include "Protocol.hpp"

class NetCol
{
public:
    NetCol(){}
    Response Excute(Request& req)
    {
        Response res(0,0);
        //std::cout << req.OPER() << std::endl;
        switch(req.OPER())
        {
            case '+':
                res.SetResult(req.X() + req.Y());
                break;
            case '-':
                res.SetResult(req.X() - req.Y());
                break;
            case '*':
                res.SetResult(req.X() * req.Y());
                break;
            case '/':
                if(req.Y() == 0)
                {
                    res.SetCode(1);//除0错误

                }
                else
                {
                    res.SetResult(req.X() / req.Y());
                }
                break;
            case '%':
                if(req.Y() == 0)
                {
                    res.SetCode(2);//除0错误
                }
                else
                {
                    res.SetResult(req.X() % req.Y());
                }
                break;
            default:
                res.SetCode(3);//符号有误
                break;
        }
        return res;
    }
};